import Vue from "vue";
import { v4 as uuidv4 } from "uuid"
import ClusterCom from "./view/view-index.vue";
import events from "events"; 
export default class ClusterInstance extends events.EventEmitter {

  constructor(options) {
    super();
    this.map = options.map;
    const comVue = Vue.extend(ClusterCom);
    this.component = new comVue();
    this.componentMap = new Map();
  }
  show() {
    let element = document.createElement("div");
    this.component.$mount(element);
    document.getElementById("map").appendChild(this.component.$el);
    // this.emit("domMounted", "success");
    const id = uuidv4();
    this.componentMap.set(id, this.component);
    const initOptions = {
      map: this.map,
      instance: this,
    };
    this.component.init(initOptions);
  }
}